'

Imports System
Imports System.Collections.Generic
Imports DotNetNuke
Imports System.Xml
Imports System.Web.UI




Namespace DGZfP.EventPublisher

    Public MustInherit Class SourceProvider
        Public Enum SourceType
            Udt
            Sql
        End Enum

#Region "| Fields |"
        Private Shared providerCollection As Generic.Dictionary(Of SourceType, SourceProvider) = New Dictionary(Of SourceType, SourceProvider)
        Public Const providerNamespace As String = "DGZfP.EventPublisher"
#End Region

        Private Shared Function Instance(ByVal Source As String) As SourceProvider
            Source = IIf(String.IsNullOrEmpty(Source), "SqlSource", Source)
            Return Instance(CType([Enum].Parse(GetType(SourceType), Source, True), SourceType))
        End Function

        Private Shared Function Instance(ByVal Source As SourceType) As SourceProvider
            If Not providerCollection.ContainsKey(Source) Then
                Dim provider As String = providerNamespace + "." + [Enum].GetName(GetType(SourceType), Source) + "Source"
                providerCollection.Add(Source, CType(Framework.Reflection.CreateObject(provider, provider), SourceProvider))
            End If
            Return providerCollection.Item(Source)
        End Function


        Protected MustOverride Function GetDataTable(ByVal Setting1 As String, ByVal setting2 As String, ByVal setting3 As String, ByVal setting4 As String) As DataTable

        Public Shared Function GetData(ByVal Source As SourceInfo) As DataTable

            Return Instance(Source.Source_Type).GetDataTable(Source.Source_Setting_100, Source.Source_Setting_2000, Source.Source_Setting_50a, Source.Source_Setting_50b)
        End Function

    End Class
End Namespace
